<script setup>
import {
  FAside,
  FButton,
  FCheckbox,
  FDrawer,
  FDropdown,
  FGrid,
  FGridItem,
  FHeader,
  FInput,
  FLayout,
  FMain,
  FSpace,
  FTree,
  FText
} from '@fesjs/fes-design'
import {useOperationPageStore} from "../../store/OperationPageStore.js";
import HelpInputView from "./HelpInputView.vue";

const operationPageStore = useOperationPageStore();
</script>

<template>
  <FLayout containerStyle="height:100%">
    <FAside width="350px">
      <FTree :data="operationPageStore.leftTreeData" @select="operationPageStore.menuSelect"/>
    </FAside>
    <FMain containerStyle="overflow: visible">
      <FLayout containerStyle="overflow: visible">
        <FHeader style="height: 100%">
          <FGrid>
            <FGridItem span="20">
              <template v-if="operationPageStore.stringSubActionList != null && operationPageStore.stringSubActionList.length>0">
                <FText>[{{ operationPageStore.actionName }}][{{ operationPageStore.actionType }}]</FText>
                <FDropdown
                    arrow
                    showSelectedOption
                    :options="operationPageStore.stringSubActionList"
                    @change="operationPageStore.stringSubActionSelectHandler"
                >
                  <FButton type="text">
                    {{ operationPageStore.stringSubActionCurrentSelect }}<FText size="small" italic type="info">&nbsp;&nbsp;...更多操作</FText>
                  </FButton>
                </FDropdown>
              </template>
              <template v-if="operationPageStore.stringSubActionList == null || operationPageStore.stringSubActionList.length===0">
                <FText>{{ operationPageStore.actionName }} {{ operationPageStore.actionType }}
                  {{ operationPageStore.inputPlaceHolder }}
                </FText>
              </template>

            </FGridItem>
          </FGrid>
          <FGrid>
            <FGridItem span="20">
              <FInput
                  type="textarea"
                  showWordLimit
                  @input="operationPageStore.inputHandle"
                  @paste="operationPageStore.handlePaste"
                  :placeholder="operationPageStore.inputPlaceHolder"
                  :disabled="operationPageStore.disableCommandInput"
                  v-model="operationPageStore.inputValue"
              />
              <FInput type="textarea"
                      rows="20"
                      v-model="operationPageStore.resultValue"/>
            </FGridItem>
            <FGridItem span="4">
              <FSpace justify="center">
                <FButton type="primary"
                         @click="operationPageStore.run()"
                         :loading="operationPageStore.running"
                         :disabled="operationPageStore.executeButtonDisabled">执行
                </FButton>
                <FButton type="text"
                         @click="operationPageStore.reset"
                         :disabled="operationPageStore.disableResetButton">重置
                </FButton>
              </FSpace>
              <FSpace vertical align="center" style="line-height: 14pt">
                <FText>{{ operationPageStore.executeRowsCount }}/{{ operationPageStore.rowsCount }}</FText>
                <FSpace justify="center">
                  <FButton
                      type="default"
                      @click="operationPageStore.exportResult"
                      size="small"
                      :disabled="operationPageStore.disableResetButton">导出结果
                  </FButton>
                  <FButton
                      type="default"
                      @click="operationPageStore.helpInput"
                      size="small"
                      :disabled="operationPageStore.disableResetButton">辅助录入
                  </FButton>
                </FSpace>
                <FCheckbox :disabled="operationPageStore.disableResetButton"
                           v-model="operationPageStore.resultSplitRow">结果二次行拆行
                </FCheckbox>
              </FSpace>
            </FGridItem>
          </FGrid>
        </FHeader>
      </FLayout>
    </FMain>
  </FLayout>
  <FDrawer
      v-model:show="operationPageStore.showHelpInputContent"
      @afterEnter="operationPageStore.openHelpInputDrawer"
      @afterLeave="operationPageStore.closeHelpInputDrawer"
      :maskClosable="false"
      :escClosable="false"
      title="辅助录入">
    <FSpace vertical>
      <HelpInputView :sub-action-list="operationPageStore.subActionList"
                     :current-select-sub-action-param-list="operationPageStore.currentSelectSubActionParamList"
                     v-model:token="operationPageStore.token"
                     v-model:select-sub-action-value="operationPageStore.subActionSelectValue"
                     @execute="operationPageStore.execute"
                     @addToExecuteTextbox="operationPageStore.addToExecuteTextbox"
                     @resetHandler="operationPageStore.resetHandler"
                     @selectSubAction="operationPageStore.selectSubAction"
      ></HelpInputView>
    </FSpace>
  </FDrawer>
</template>

<style scoped>


</style>
